#include <my_header.h>

void log(int num, const char *funname, const char *name)
{
    time_t nowtime;
    struct tm *timeinfo;
    char timebuf[60];
    time(&nowtime);
    timeinfo=localtime(&nowtime);
    strftime(timebuf, 60, "%Y-%m-%d %H:%M:%S", timeinfo);
    
    int time_len=strlen(timebuf);

    char *path_info="my_info.log";
    int fd_info=open(path_info,O_RDWR|O_APPEND|O_CREAT,0777);
    ERROR_CHECK(fd_info ,-1,"infoOpen");

    char buf[60]={0};
    sprintf(buf,"  %s: %s: %d \n", name,funname,num);
    int len=strlen(buf);
    write(fd_info,timebuf,time_len);
    write(fd_info,buf,len);

}

